<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
    <title>Document</title>
    <style type="text/css">
      .img2 {
        width: 600px;
        position: absolute;
        display: none;
      }
    </style>

    <script>
      $(function () {
        // 设置鼠标事件
        $(".img1").mouseover(function () {
            console.log("over 执行了")
        //   $(".img2").show();
            $(".img2").css("display", "inline")
        });
        $(".img1").mouseout(function () {
            console.log("out 执行了")
          $(".img2").hide();
        });
        $(".img1").mousemove(function(e){
            // 获取鼠标的坐标
            // console.log("鼠标的坐标是:", e.pageX, e.pageY)
            // 将鼠标的坐标设置给 img2 
            $(".img2").css({left:e.pageX+20, top: e.pageY+20})
        })
      });
    </script>
  </head>
  <body>
    <img class="img1" src="./assets/img01.jpg" />

    <img class="img2" src="./assets/img01.jpg" />
  </body>
</html>
